﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using Microsoft.VisualBasic.CompilerServices;
using Microsoft.VisualBasic;

namespace td.Core
{
   public class Register
    {
        [DllImport("kernel32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        private static extern void GetSystemInfo(ref SystemInfo lpSystemInfo);
        [StructLayout(LayoutKind.Sequential)]
        private struct SystemInfo
        {
            public int dwOemId;
            public int dwPageSize;
            public int lpMinAppAddress;
            public int lpMaxAppAddress;
            public int dwActiveProcessorMask;
            public int dwNumberOfProcessors;
            public int dwProcessorType;
            public int dwAllocationGranularity;
            public int dwReserved;
        }
        static  string CodeString;
    
        public static  string  GetCode()
        {
            SystemInfo systemInfo = new SystemInfo(); ;
            GetSystemInfo(ref systemInfo);
            string text = Conversions.ToString(systemInfo.dwReserved);
            if (Conversion.Val(Strings.Mid(text, 1, 1)) <= 4.0)
            {
                short arg_44_0 = 2;
                short num = checked((short)Strings.Len(text));
                for (short num2 = arg_44_0; num2 <= num; num2 += 1)
                {
                    VBMath.Randomize();
                    string text2 = Conversions.ToString(VBMath.Rnd() * 10000f);
                    text2 = Strings.Mid(text2, 2, 1);
                    CodeString = CodeString + Strings.Mid(text, (int)num2, 1) + text2;
                }
            }
            else
            {
                short arg_AB_0 = 2;
                short num3 = checked((short)Strings.Len(text));
                for (short num2 = arg_AB_0; num2 <= num3; num2 += 1)
                {
                    VBMath.Randomize();
                    string text2 = Conversions.ToString(VBMath.Rnd() * 10000f);
                    text2 = Strings.Mid(text2, 2, 1);
                    CodeString = CodeString + text2 + Strings.Mid(text, (int)num2, 1);
                }
            }
            CodeString = Strings.Mid(text, 1, 1) + CodeString;
            return CodeString;
        }
    }
}
